{extend name="base" /}
{block name="body"}
<!-- 主要内容 开始 -->
<div class="weui-tab__bd-item">
    <header class="weui-navBar weui-navBar-fixed">
        <a href="javascript:history.go(-1);" class="weui-navBar-item">
            <i class="icon iconfont icon-fanhui"></i>
        </a>
        <div class="weui-center">
            <span class="weui-center-title">修改密码</span>
        </div>
        <a href="javascript:;" class="weui-navBar-item">
        </a>
    </header>
    <div class="weui-tab">
      <div class="weui-navbar">
        <div class="weui-navbar__item weui-bar__item--on" href="#tab1">
          <a>登陆密码</a>
        </div>
        <div class="weui-navbar__item" href="#tab2">
          <a>支付密码</a>
        </div>
      </div>
      <div class="weui-tab__bd">
        <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">原 密 码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" id="pass" placeholder="请输入原登陆密码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">新 密 码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" id="pwd" placeholder="请输入新密码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">确认密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" id="rep_pwd" placeholder="请输入确认密码">
                </div>
            </div>
        </div>
        <div id="tab2" class="weui-tab__bd-item">
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">登陆密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" id="paypass" placeholder="请输入登陆密码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">新 密 码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" id="paypwd" placeholder="请输入新支付密码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">确认密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="password" id="rep_paypwd" placeholder="请输入确认支付密码">
                </div>
            </div>
        </div>
        <div class="weui-btn-area">
            <button class="weui-btn weui-btn_primary btn">确定</button>
        </div>
      </div>
    </div>
</div>
<!-- 主要内容 结束 -->
{/block}
{block name="js"}
<script type="text/javascript">
  $(function () {
    $('.btn').click(function() {
        var type = $('.weui-bar__item--on').attr("href");
        if (type =='#tab1') {
            var pass = $('#pass').val();
            var pwd = $('#pwd').val();
            var rep_pwd = $('#rep_pwd').val();
        }else{
            var pass = $('#paypass').val();
            var pwd = $('#paypwd').val();
            var rep_pwd = $('#rep_paypwd').val();
        }
        if (!pass) $.toptip('原密码不能为空');
        else if (!pwd) $.toptip('新密码不能为空!');
        else if (pwd!==rep_pwd) $.toptip('两次输入密码不一致!');
        else $.post('modify.html',{pass:pass,pwd:pwd,rep_pwd:rep_pwd,type:type},function(result) {
            if (result.code === 1) {
                $.toast(result.msg,'text');
                setTimeout(function(){
                    location.href = result.url;
                },600);
            } else {
                $.toptip(result.msg);
            }
        });
    });
  });
</script>
{/block}